let addDialog =$("#addDialog");
let  form=addDialog[0].querySelector("form");
let  but=addDialog[0].querySelector("._serv");



but.onclick=function (){
    let param =new URLSearchParams(new FormData(form));
    console.info(param.toString());

    fetch("admin-add.let",{
        method: 'POST', // *GET, POST, PUT, DELETE, etc.
        mode: 'cors', // no-cors, *cors, same-origin
        cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
        credentials: 'same-origin', // include, *same-origin, omit
        headers: {
            'Content-Type': 'application/json'
            // 'Content-Type': 'application/x-www-form-urlencoded',
        },
        redirect: 'follow', // manual, *follow, error
        referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
        body:param
    }).then(r=>r.json()).then(data=>{
        if (data.ok){
            addDialog.modal('heid');
            form.reset();
        }else {
            alert(data.msg);
        }
    }).catch(e=>{
        console.error(e);
    })
}

export  default function (){

}












/*let form=addDialog[0].querySelector("form");//原生标签元素
let but=addDialog[0].querySelector("._serv");
console.debug(form,but);

but.onclick=function (){
    //验证
    let param=new URLSearchParams(new FormData(form));
    fetch("admin-add.let",{
        method: 'POST', // *GET, POST, PUT, DELETE, etc.
        mode: 'cors', // no-cors, *cors, same-origin
        cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
        credentials: 'include', // include, *same-origin, omit
        headers: {
            'Content-Type': 'application/json'
            // 'Content-Type': 'application/x-www-form-urlencoded',
        },
        redirect: 'follow', // manual, *follow, error
        referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
        //body: JSON.stringify(data) // body data type must match "Content-Type" header
        body:param
    }).then(r=>r.json()).then(data=>{

    }).catch(e=>{
        console.error(e);
    });


}*/

